﻿using MediatR;
using S.Produce.Domains;
using S.Produce.Infrastructure;
using S.Produce.Read.Api.Application.Commands.DeliveryCommands;

namespace S.Produce.Read.Api.Application.CommandHandlers.DeliveryCommandHandlers
{
    public class GetAllDeliveryCommandsHandler:IRequestHandler<GetAllDeliveryCommands,List<Delivery>>
    {
        private readonly IRepository<Delivery> _repository;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="repository"></param>
        public GetAllDeliveryCommandsHandler(IRepository<Delivery> repository)
        {
            _repository = repository;
        }

        public async Task<List<Delivery>> Handle(GetAllDeliveryCommands request, CancellationToken cancellationToken)
        {
              return await _repository.GetAllAsync();
        }
    }
}
